package com.david.controller;




import com.david.common.lang.Result;
import com.david.entity.User;
import com.david.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * @author David
 * @since 2022-05-09
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    /**
     * 测试查询结果
     * @return
     */
    @RequiresAuthentication
    @GetMapping("/index")
    public Result index(){
        User user = userService.getById(1L);
        return Result.success(user);
    }
    @PostMapping("/save")
    public Result save(@Validated @RequestBody User user){

        return Result.success(user);
    }

}
